package com.wh1200.mybatis.xmlless.model.criteria

import com.wh1200.mybatis.xmlless.AnnotatedElementDetailInfo
import com.wh1200.mybatis.xmlless.enums.TestType

/**
 * 条件参数
 *
 * @author 吴昊
 * @date 2023/12/11
 * @version 1.0
 * @since v4.0.0
 */
data class CriteriaParameter(
    val name: CriteriaParamName,
    val element: AnnotatedElementDetailInfo?,
    val specificValue: Boolean = false,
    /** whether parameter is marked with annotation @NotNull */
    val isNotNull: Boolean,
    /** whether parameter is marked with annotation @NotBlank */
    val isNotBlank: Boolean,
    /** whether parameter is marked with annotation @NotEmtpy */
    val isNotEmpty: Boolean,
    /** 参数条件判断类型 */
    val testTypes: List<TestType>,
    /** 忽略所有针对参数的条件判断 */
    val noIfWrap: Boolean
) {

  fun clone(name: String, isNotNull: Boolean, isNotBlank: Boolean, isNotEmpty: Boolean): CriteriaParameter {
    return CriteriaParameter(
        CriteriaParamName(name, this.name.origin), element, specificValue,
        isNotNull, isNotBlank, isNotEmpty, testTypes, noIfWrap
    )
  }

}
